/*
 * @Author: Ryan Huang
 * @Description:
 * @Date: 2019-04-26 22:40:10
 */
package controllers

import (
	"encoding/json"
	"fmt"

	"github.com/astaxie/beego"
)

type UserController struct {
	beego.Controller
}

func (this *UserController) Get() {
	this.Ctx.WriteString("this is a controller1")
}

func (this *UserController) Index() {
	this.Ctx.WriteString("this is a controller Index")
}

func (this *UserController) GetInfo() {
	var params = this.Ctx.Input.Params()
	fmt.Println(params)
	//json1, _ := json.Marshal(params)
	var data string
	for k, item := range params {
		if k == ":splat" {
			continue
		}
		data += item
	}
	//id := this.Ctx.Input.Param(":id")
	this.Ctx.WriteString("getinfo data = " + data)
}

func toJson(params interface{}) string {
	json, _ := json.Marshal(params)
	return string(json)
}
